import request from "@/plugin/axios";

const BASE_URL = "sys/dict";

export function DictList(data) {
  return request({
    url: BASE_URL + "/page",
    method: "get",
    params: data,
  });
}

export function DictAdd(data) {
  return request({
    url: BASE_URL,
    method: "post",
    data,
  });
}

export function DictUpdate(data) {
  return request({
    url: BASE_URL + "/" + data.id,
    method: "put",
    data,
  });
}

export function DictDetail(dictId) {
  return request({
    url: BASE_URL + "/" + dictId + "/item",
    method: "get",
  });
}

export function DictDetailAdd({ dictId, dictList }) {
  return request({
    url: BASE_URL + "/" + dictId + "/item",
    method: "post",
    data: dictList,
  });
}

// 删除数据字典类型
export function DictDel(dictKeyId) {
  return request({
    url: BASE_URL + "/" + dictKeyId,
    method: "delete",
  });
}

// 启用/停用数据字典
export function DictStatusChange(dictKeyId) {
  return request({
    url: BASE_URL + "/" + dictKeyId + "/state",
    method: "put",
  });
}

export function DictKeys(keys) {
  return request({
    url: BASE_URL + "/" + keys,
    method: "get",
  });
}
